module Types where

import Numeric

type PdfFunction = Double -> Double
type CdfFunction = Double -> Double

type Price  = Double
type OrderPrice = Maybe Double

{-
instance Show Price where
        showsPrec _ x r = showFFloat (Just 4) x r
-}
data BarData = BarData {
           barOpen   :: Double,
           barHigh   :: Double,
           barLow    :: Double,
           barClose  :: Double,
           barVolume :: Double
        } deriving (Show, Eq)

-- this function provides f(h,l,sl, bar)
type OptimizationFunction = Double->Double->Double->Double

pdf2cdf :: PdfFunction -> CdfFunction
pdf2cdf f = undefined

type Symbol = String

data Currency = EUR | USD | CHF
        deriving (Show)

data OrderType = BuyLimit | SellStop

data Order = BuyOrder {
                orderVolume     :: Double,
                orderPrice      :: Double,
                orderStopLoss   :: Double,
                orderTakeProfit :: Double
        }
        | SellOrder {
                orderVolume     :: Double,
                orderPrice      :: Double,
                orderStopLoss   :: Double,
                orderTakeProfit :: Double
        } deriving (Show)

showMaybe :: Maybe Double->String
showMaybe (Just x) = "Just "++(showFFloat (Just 4) x "")
showMaybe Nothing = "Nothing"

showMaybeArray :: [Maybe Double]->String
showMaybeArray (x:xs)
        | null xs       = showMaybe x
        | otherwise     = (showMaybe x)++", "++(showMaybeArray xs)
showMaybeArray []     = ""

data FxSymbol = FxSymbol {baseCur :: Currency, quoteCur :: Currency}

instance Show FxSymbol where
        show x = (show $ baseCur x) ++ (show $ quoteCur x)
